package com.ysq.www.api.front.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysq.www.api.front.entity.SlideShow;
import com.ysq.www.api.front.service.ISlideShowService;
import com.ysq.www.common.annotation.AuthToken;
import com.ysq.www.common.result.ResultMsg;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 轮播图表 前端控制器
 * </p>
 *
 * @author dql
 * @since 2020-08-07
 */
@Slf4j
@RestController
@RequestMapping("/front/slideShow")
public class SlideShowController {

    @Autowired
    private ISlideShowService slideShowService;

    /**
     * 查询首页轮播图数据
     * @return
     */
    @GetMapping("/search")
    @AuthToken
    public ResultMsg search(){
        QueryWrapper<SlideShow> wrapper = new QueryWrapper();
        wrapper.eq("recommend",1).eq("status",0).orderByDesc("serial").last("limit 2");
        List<SlideShow> list = slideShowService.list(wrapper);
        return ResultMsg.SUCCESS.setNewMsg("查询成功").setNewData(list);
    }




}
